#!/bin/bash -x

bri="br0"
tap="tap"
ip="10.0.0.1/24"
broadcast="10.0.0.255"

sudo brctl addbr $bri
sudo ip addr add $ip broadcast $broadcast dev $bri
sudo ip link set dev $bri up

sudo tunctl -t ${tap}0 -u $(whoami)
sudo tunctl -t ${tap}1 -u $(whoami)
sudo ip link set dev ${tap}0 up
sudo ip link set dev ${tap}1 up
sudo brctl addif $bri ${tap}0
sudo brctl addif $bri ${tap}1